import request from '@/utils/request'
import axios from 'axios'
export function postObject(policy, file) {
  let formdata = new FormData()
  formdata.append('OSSAccessKeyId', policy.accessid)
  formdata.append('policy', policy.policy)
  formdata.append('Signature', policy.signature)
  formdata.append('key', policy.dir + file.name)
  formdata.append('file', file)
  let headers = {
    'Content-Type': 'multipart/form-data'
  }
  return request({
    url: policy.host,
    method: 'POST',
    headers: headers,
    data: formdata
  })
}
export function deleteObject(url) {
  return request({
    url: '/attachment/aliyunoss/delete_object',
    method: 'GET',
    params: {
      url
    }
  })
}
export function infoObject(url) {
  return new Promise((resolve, reject) => {
    axios.get(url + '?x-oss-process=image/info').then(function(res) {
      resolve(res.data)
    })
  })
}
